#include "QtUI/ProjectGeneralInfoWidget.qth"
#include "QtUI/ProjectGeneralInfoWidget.moh"
#include <QtGui/QLineEdit>
#include <QtGui/QPlainTextEdit>
#include <QtGui/QGridLayout>
#include <QtGui/QLabel>
#include <QtGui/QRegExpValidator>

namespace QtUI
{

ProjectGeneralInfoWidget::ProjectGeneralInfoWidget( QWidget* pParent /*= NULL*/)
	: QWidget( pParent)
{
	QGridLayout* pLayout = new QGridLayout;
	this->setLayout( pLayout);

	// Project name
	QLabel* pPrjNameLabel = new QLabel;
	pNameEditor_ = new QLineEdit;
	pPrjNameLabel->setText( tr( "Name"));
	pPrjNameLabel->setBuddy( pNameEditor_);
	pLayout->addWidget( pPrjNameLabel, 0, 0);
	pLayout->addWidget( pNameEditor_, 0, 1);
	pPrjNameValidator_ = new QRegExpValidator( QRegExp("[a-zA-Z]+([a-zA-Z0-9_\\s])*"), this);
	pNameEditor_->setValidator( pPrjNameValidator_);

	QLabel* pPrjDescrLabel = new QLabel;
	pDescriptionEditor_ = new QPlainTextEdit;
	pPrjDescrLabel->setText( tr( "Description"));
	pPrjDescrLabel->setBuddy( pDescriptionEditor_);
	pPrjDescrLabel->setAlignment( Qt::AlignTop | Qt::AlignLeft);
	pLayout->addWidget( pPrjDescrLabel, 1, 0);
	pLayout->addWidget( pDescriptionEditor_, 1, 1);

	connect( pNameEditor_, SIGNAL( textChanged( const QString&)), this, SIGNAL( projectNameChanged( const QString&)));
}

// ---------------------------------------------------------------------------------------------------------------------

QString ProjectGeneralInfoWidget::projectName() const
{
	return pNameEditor_->text().trimmed();
}

// ---------------------------------------------------------------------------------------------------------------------

void ProjectGeneralInfoWidget::setProjectName( const QString& newName)
{
	pNameEditor_->setText( newName);
}

// ---------------------------------------------------------------------------------------------------------------------

QString ProjectGeneralInfoWidget::description() const
{
	return pDescriptionEditor_->toPlainText().trimmed();
}

// ---------------------------------------------------------------------------------------------------------------------

void ProjectGeneralInfoWidget::setDescription( const QString& newDescription)
{
	pDescriptionEditor_->setPlainText( newDescription);
}


} // namespace QtUI
